package com.uzai.console.web.cms;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.cms.personalcenter.CmsPersonalCenterConfigDto;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.cms.CmsPersonalCenterService;
import com.uzai.console.vo.cms.personalcenter.CmsPersonalCenterConfigVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * CMS小程序|个人中心设置
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "个人中心",tags = "CMS小程序|个人中心")
@ApiSort(7)
@RestController
public class CmsPersonalCenterController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(CmsPersonalCenterController.class);

    @Autowired
    private CmsPersonalCenterService cmsPersonalCenterService;

    @ApiOperation(value = "查询CMS个人中心配置信息", notes = "查询CMS个人中心配置信息", response = CmsPersonalCenterConfigVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/cmsBase/findCmsPersonalCenter")
    public Object findCmsPersonalCenter(){
        return cmsPersonalCenterService.findCmsPersonalCenter(getLoginInfo().getMerId());
    }

    @SystemLogType(model = SystemModelEnum.CmsPersonalCenter, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "保存CMS个人中心设置信息", notes = "保存CMS个人中心设置信息")
    @ApiOperationSupport(order = 2)
    @PostMapping("/cmsBase/updateCmsPersonalCenter")
    public Object updateCmsPersonalCenter(@RequestBody CmsPersonalCenterConfigDto cmsPersonalCenterConfigDto){
        cmsPersonalCenterService.updateCmsPersonalCenter(cmsPersonalCenterConfigDto);
        return true;
    }

    @ApiOperation(value = "查询CMS官方默认的个人中心配置", notes = "查询CMS官方默认的个人中心配置", response = CmsPersonalCenterConfigVo.class)
    @ApiOperationSupport(order = 3)
    @PostMapping("/cmsBase/findCmsPersonalCenterByDefault")
    public Object findCmsPersonalCenterByDefault(){
        return cmsPersonalCenterService.findCmsPersonalCenterByDefault();
    }


}
